package com.example.tests;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
//import java.util.Random;
import java.util.Set;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class GroupModificationTests extends TestBase {
	
	Random rnd = new Random();
	
	@DataProvider(name = "modifyAnyGroupToNewGroup")
	public Iterator<Object[]> modifyRandomGroup() {
		Set<GroupObject> groups = app.getGroupHelper().getGroups();
		GroupObject anyGroup = groups.iterator().next();
	
		List<Object[]> list = new ArrayList<Object[]>();
		GroupObject newGroup = new GroupObject()
				.setName("name"+rnd.nextInt())
				.setHeader("header"+rnd.nextInt())
				.setFooter("footer"+rnd.nextInt());
		list.add(new Object[]{anyGroup,newGroup});
		return list.iterator();
	}
	

	@Test(dataProvider = "modifyAnyGroupToNewGroup")
	public void testGroupCanBeModified(GroupObject anyGroup, GroupObject newGroup) throws Exception {
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().modifyGroup(anyGroup, newGroup);
		Set<GroupObject> newList = app.getGroupHelper().getGroups();

		verifyGroupModificated (oldList, anyGroup, newGroup, newList);
		//validate
	}
}
